namespace RIS.TMP.WEB.APP.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class AllContext7 : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.MRSaveRestore",
                c => new
                    {
                        SResId = c.Int(nullable: false, identity: true),
                        ReId = c.Int(nullable: false),
                        ResId = c.Int(nullable: false),
                        RemarkRestore = c.String(),
                        Invoine = c.String(),
                        ChangeRestore = c.String(),
                        FirstSucdate = c.DateTime(),
                        FirstSucTime = c.DateTime(),
                        LastSucdate = c.DateTime(),
                        LastSucTime = c.DateTime(),
                        DaySave = c.String(),
                        HourSave = c.String(),
                        PriceRestorespares = c.String(),
                        PriceRestoreH = c.String(),
                        PriceRestoreAll = c.String(),
                        MRPId = c.Int(nullable: false),
                        Remarks = c.String(),
                        RecordStatus = c.String(),
                        CreateBy = c.String(),
                        CreateWhen = c.DateTime(),
                        UpdateBy = c.String(),
                        UpdateWhen = c.DateTime(),
                    })
                .PrimaryKey(t => t.SResId)
                .ForeignKey("dbo.MRPoint", t => t.MRPId, cascadeDelete: true)
                .ForeignKey("dbo.MRestoreToRepair", t => t.ReId, cascadeDelete: true)
                .ForeignKey("dbo.MRestoreToAdmin", t => t.ResId, cascadeDelete: true)
                .Index(t => t.MRPId)
                .Index(t => t.ReId)
                .Index(t => t.ResId);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.MRSaveRestore", new[] { "ResId" });
            DropIndex("dbo.MRSaveRestore", new[] { "ReId" });
            DropIndex("dbo.MRSaveRestore", new[] { "MRPId" });
            DropForeignKey("dbo.MRSaveRestore", "ResId", "dbo.MRestoreToAdmin");
            DropForeignKey("dbo.MRSaveRestore", "ReId", "dbo.MRestoreToRepair");
            DropForeignKey("dbo.MRSaveRestore", "MRPId", "dbo.MRPoint");
            DropTable("dbo.MRSaveRestore");
        }
    }
}
